﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using VIP.Extension;

public class MachineCodePanel : MonoBehaviour {


    private Button closeBtn;
    private Text codeText;
    private Button copyBtn;
    private Text copyBtnText;


    void Start () {
        codeText = gameObject.FindChildByName("MachineCodeText").GetComponent<Text>();
        closeBtn = gameObject.FindChildByName("CloseBtn").GetComponent<Button>();
        closeBtn.onClick.AddListener(() =>
        {
            transform.CGHide();
        });
        copyBtn = gameObject.FindChildByName("CopyBtn").GetComponent<Button>();
        copyBtnText = copyBtn.transform.Find("Text").GetComponent<Text>();
        copyBtn.onClick.AddListener(() =>
        {
            VIPFileUtil.Copy(codeText.text);
            copyBtnText.text = "复制成功";
        });
        transform.CGHide();
    }

    public string SetCode {
        set {
            codeText.text = value;
        }
    }

    public void Show() {
        transform.CGShow();
    }

}
